package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlMaterialOd;
import com.ruoyi.hualian.service.IHlMaterialOdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 材质ODController
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/od")
public class HlMaterialOdController extends BaseController
{
    @Autowired
    private IHlMaterialOdService hlMaterialOdService;

    /**
     * 查询材质OD列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlMaterialOd hlMaterialOd)
    {
        startPage();
        List<HlMaterialOd> list = hlMaterialOdService.selectHlMaterialOdList(hlMaterialOd);
        return getDataTable(list);
    }

    /**
     * 导出材质OD列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:export')")
    @Log(title = "材质OD", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlMaterialOd hlMaterialOd)
    {
        List<HlMaterialOd> list = hlMaterialOdService.selectHlMaterialOdList(hlMaterialOd);
        ExcelUtil<HlMaterialOd> util = new ExcelUtil<HlMaterialOd>(HlMaterialOd.class);
        util.exportExcel(response, list, "材质OD数据");
    }

    /**
     * 获取材质OD详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:query')")
    @GetMapping(value = "/{odId}")
    public AjaxResult getInfo(@PathVariable("odId") Long odId)
    {
        return success(hlMaterialOdService.selectHlMaterialOdByOdId(odId));
    }

    /**
     * 新增材质OD
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:add')")
    @Log(title = "材质OD", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlMaterialOd hlMaterialOd)
    {
        return toAjax(hlMaterialOdService.insertHlMaterialOd(hlMaterialOd));
    }

    /**
     * 修改材质OD
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:edit')")
    @Log(title = "材质OD", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlMaterialOd hlMaterialOd)
    {
        return toAjax(hlMaterialOdService.updateHlMaterialOd(hlMaterialOd));
    }

    /**
     * 删除材质OD
     */
    @PreAuthorize("@ss.hasPermi('hualian:od:remove')")
    @Log(title = "材质OD", businessType = BusinessType.DELETE)
	@DeleteMapping("/{odIds}")
    public AjaxResult remove(@PathVariable Long[] odIds)
    {
        return toAjax(hlMaterialOdService.deleteHlMaterialOdByOdIds(odIds));
    }
}
